-- 这个文件变动的时候自动重新加载
vim.cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerCompile
  augroup end
]])

local ensure_packer = function()
    local fn = vim.fn
    local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
    if fn.empty(fn.glob(install_path)) > 0 then
        fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
        vim.cmd [[packadd packer.nvim]]
        return true
    end
    return false
end

local packer_bootstrap = ensure_packer()

return require('packer').startup(function(use)
    -- packer self
    use 'wbthomason/packer.nvim'
    -- 回车自动扩展区块选择
    use 'gcmt/wildfire.vim'
    -- 显示 mark
    use 'kshenoy/vim-signature'
    -- 显示对齐线
    use 'Yggdroot/indentLine'
    -- 状态栏
    use 'nvim-lualine/lualine.nvim'
    -- clang-format 支持
    use 'rhysd/vim-clang-format'
    -- 纵向对齐
    use 'godlygeek/tabular'
    -- 历史记录列表
    use 'vim-scripts/undotree.vim'
    -- 头文件切换
    use 'derekwyatt/vim-fswitch'
    -- 模糊匹配
    use { 'nvim-telescope/telescope.nvim', branch = '0.1.x' }
    use 'lpoto/telescope-tasks.nvim'
    -- 修改相匹配的符号
    use 'tpope/vim-surround'
    -- 翻译
    use 'voldikss/vim-translator'
    -- 自动格式化
    use 'Chiel92/vim-autoformat'
    -- nerdtree 相关
    use 'scrooloose/nerdtree'
    use 'scrooloose/nerdcommenter'
    use 'Xuyuanp/nerdtree-git-plugin'
    -- git 相关
    use 'tpope/vim-fugitive'
    use 'lewis6991/gitsigns.nvim'
    use 'nvim-lua/plenary.nvim'
    -- 主题配色
    use 'morhetz/gruvbox'
    -- gist
    use 'mattn/webapi-vim'
    use 'mattn/gist-vim'
    -- 标签列表
    use 'majutsushi/tagbar'
    -- 标签管理
    use 'xolox/vim-misc'
    use 'xolox/vim-easytags'
    -- easy-motion
    use 'easymotion/vim-easymotion'
    -- 语言相关
    use 'tbastos/vim-lua'
    use 'rust-lang/rust.vim'
    -- tmux conf 支持
    use 'tmux-plugins/vim-tmux'
    -- 跳转。用的是 rg
    use 'pechorin/any-jump.vim'
    -- LSP
    use 'williamboman/mason.nvim'
    use 'williamboman/mason-lspconfig.nvim'
    use 'neovim/nvim-lspconfig'
    use 'hrsh7th/cmp-nvim-lsp'
    use 'hrsh7th/cmp-nvim-lua'
    use 'hrsh7th/cmp-buffer'
    use 'hrsh7th/cmp-path'
    use 'hrsh7th/nvim-cmp'
    use 'SirVer/ultisnips'
    use 'honza/vim-snippets'
    use 'quangnguyen30192/cmp-nvim-ultisnips'
    -- quickfix 强化
    use 'folke/trouble.nvim'
    use 'kyazdani42/nvim-web-devicons'
    -- treesitter
    use 'p00f/nvim-ts-rainbow'
    use 'nvim-treesitter/nvim-treesitter'
    -- 文件夹对比
    use 'will133/vim-dirdiff'
    -- nvim api补全
    use 'folke/neodev.nvim'
    -- 调试
    use 'mxsdev/nvim-dap-vscode-js'
    use {
        'microsoft/vscode-js-debug',
        opt = true,
        run = 'npm install && npx gulp vsDebugServerBundle && mv dist out'
    }
    use 'mfussenegger/nvim-dap'
    use 'rcarriga/nvim-dap-ui'
    use 'nvim-telescope/telescope-dap.nvim'
    use 'HUAHUAI23/telescope-dapzzzz'
    use 'theHamsta/nvim-dap-virtual-text'
    use {
        'mfussenegger/nvim-dap-python',
        run = 'python3 -m pip install debugpy'
    }
    use 'rcarriga/cmp-dap'


    -- Automatically set up your configuration after cloning packer.nvim
    -- Put this at the end after all plugins
    if packer_bootstrap then
        require('packer').sync()
    end
end)
